package com.suning.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.suning.service.ProductListService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.Map;

@Controller
@RequestMapping("/product")
public class ProductListController {
    @Resource
    private ProductListService productListService;
    @RequestMapping("/list")
    public String list(Model model,
                       @RequestParam(value = "psize",defaultValue = "1") int psize,
                       @RequestParam(value = "pageSize",defaultValue = "8") int pageSize, int epcid){
        System.out.println("接收到一个浏览器请求......");

        Map<String, Page> resultMap = productListService.list(psize,pageSize,epcid);

        model.addAttribute("resultMap",resultMap);
        return "product-list";
    }
}
